﻿/// <reference path="../../js/jquery-2.1.1.min.js" />
/// <reference path="../../js/jquery-2.1.0-vsdoc.js" />

//********************************************************************************//
//程式共用變數及物件宣告														  //
//																				  //
//																				  //	
//																				  //	
//********************************************************************************//
var global_TableName = "";

//換成jQuery的ready事件  by Tony
//window.onload = PageLoad;
$.ready(PageLoad);
var program_id = "CLASS_DESC.aspx";
var _DialogWidth = "520px";
var _DialogHeight = "220px";
var dialogStr = "dialogWidth=" + _DialogWidth + ";dialogHeight=" + _DialogHeight + ";center=yes;border=thin;help=no;status=no;resizable=no;toolbar=no;location=no;title=no";


//--------------------------------------------------------------------------------/
//維護程式 - 表單載入															  /
//功能:當表單載入時初始值														  /
//函式名稱 = subfrmload															  /
//--------------------------------------------------------------------------------/
function PageLoad() {
    try {

        /*if (document.all.drpDELIVERY_TERM.value=="FOB_Seaport")
		{
			document.all.lblSEAPORT.style.display=""; 
			document.all.txtSEAPORT.style.display=""; 
		}
		else
		{	
			document.all.lblSEAPORT.style.display="none"; 
			document.all.txtSEAPORT.style.display="none"; 
		}*/
        if ($("#rdoVENDOR_TYPE_0").prop("checked")) {
            $("#txtVENDOR_NO").attr('disabled', false);
            $("#lblVENDOR_ENGLISHNAME").css("color", "black");
            $("#lblVENDOR_CHINESENAME").css("color", "red");
            $("#drpCOUNTRY").val('Taiwan');
            $("#drpINVOICE_COUNTRY").val('Taiwan');

        }
        else {
            $("#txtVENDOR_NO").attr('disabled', true);
            $("#lblVENDOR_ENGLISHNAME").css("color", "red");
            $("#lblVENDOR_CHINESENAME").css("color", "black");
        }
        if ($("#txtVENDOR_NO").val() != "") {
            $("#txtVND_PASSWORD").css("display", "none");
        }
        if ($("#rdoVENDOR_TYPE_1").prop("checked")) {
            if ($("#DIV2") != undefined)//
            {
                if ($("#drpCURRENCY_TYPE").val() == "USD") {
                    $("#lblACH").css("color", "red");
                    $("#txtACH").attr("disabled", false);
                }
                else {

                    $("#lblACH").css("color", "black");
                    $("#txtACH").attr("disabled", true);
                    $("#txtACH").val("");
                }

            }
            if ($("#DIV3") != undefined)//
            {
                if ($("#drpCURRENCY_TYPE").val() == "EUR") {
                    $("#lblIACH").css("color", "red");
                    $("#txtIACH").attr("disabled", false);
                }
                else {
                    $("#lblIACH").css("color", "black");
                    $("#txtIACH").attr("disabled", true);
                    $("#txtIACH").val("");
                }
            }
        }

    }
    catch (e) {
        alert(e.Message);
    }
    finally {

    }


}
//--------------------------------------------------------------------------------/
//維護程式 - 離開																  /
//功能:離開維護表單																  /
//函式名稱 = DialogBtnExit_OnClick												  /
//--------------------------------------------------------------------------------/
function DialogBtnExit_OnClick() {
    this.close();
}

function DialogBtnCHANGE_PASSWORD_OnClick() {
    /* Mark By Ben P3512S0159-針對B2B網站SCA弱點掃描修正程式
	document.all.txtVND_PASSWORD.style.display="";
	document.all.btnCHANGE_PASSWORD.style.display="none";
	*/

    /* add By Ben P3512S0159-針對B2B網站SCA弱點掃描修正程式*/
    $("#txtVND_PASSWORD").css("display", "block");
    $("#btnCHANGE_PASSWORD").css("display", "none");

}


function COPY(X) {
    X.value = $("#txtADDRESS").val();
    return false;
}


function password(X) {
    if ($("#txtVND_PASSWORD").val().length != 8) {
        $("#lblVND_PASSWORD_ERR").text(GetMessageByID("MSG022").text);
    }
    else {
        alert(GetMessageByID("MSG023").text + X.value);
    }


}



function DialogBtnSave_OnClick() {
    try {

        //
        if ($("#rdoVENDOR_TYPE_0").prop("checked")) {
            if ($("#txtVENDOR_NO").val() == "") {
                $("#lblVENDOR_NO_ERR").text(GetMessageByID("MSG019").text);
            }
            else {
                $("#lblVENDOR_NO_ERR").text("");
                if ($("#txtVENDOR_NO").attr("readonly") == false) {

                    Vendor_Id_Check($("#txtVENDOR_NO"));


                }

            }
        }

        if ($("#txtVND_PASSWORD").css("display") != "none") {
            if ($("#txtVND_PASSWORD").val() == "") {
                $("#lblVND_PASSWORD_ERR").text(GetMessageByID("MSG019").text);
            }
            else {
                /* Mark By Ben P3512S0159-針對B2B網站SCA弱點掃描修正程式
                document.all.lblVND_PASSWORD_ERR.innerText="";
                */
                /* add By Ben P3512S0159-針對B2B網站SCA弱點掃描修正程式*/
                var m_Empty = "";
                $("#lblVND_PASSWORD_ERR").text(m_Empty);
                if ($("#txtVND_PASSWORD").val().length != 8) {
                    $("#lblVND_PASSWORD_ERR").text(GetMessageByID("MSG022").text);
                }

            }
        }

        if ($("#rdoVENDOR_TYPE_0").prop("checked")) {
            if ($("#txtVENDOR_CHINESENAME").val() == "") {
                $("#lblVENDOR_CHINESENAME_ERR").text(GetMessageByID("MSG019").text);
            }
            else {
                $("#lblVENDOR_CHINESENAME_ERR").text("");
            }
        }
        else {
            if ($("#txtVENDOR_ENGLISHNAME").val() == "") {
                $("#lblVENDOR_ENGLISHNAME_ERR").text(GetMessageByID("MSG019").text);
            }
            else {
                $("#lblVENDOR_ENGLISHNAME_ERR").text("");
            }
        }

        if ($("#txtTEL1").val() == "") {
            $("#lblTEL1_ERR").text(GetMessageByID("MSG019").text);
        }
        else {
            $("#lblTEL1_ERR").text("");
            /*if(isNaN(document.all.txtTEL1.val()))
                {
                    document.all.lblTEL1_ERR.innerText=GetMessageByID("MSG024").text;
                }*/
        }


        if ($("#txtFAX1").val() == "") {
            $("#lblFAX1_ERR").text(GetMessageByID("MSG019").text);
        }
        else {
            $("#lblFAX1_ERR").text("");
            /*if(isNaN(document.all.txtFAX1.val()))
            {
                document.all.lblFAX1_ERR.innerText=GetMessageByID("MSG024").text;
            }*/
        }

        if ($("#txtPROFILE_PRODUCT").val() == "") {
            $("#lblPROFILE_PRODUCT_ERR").text(GetMessageByID("MSG019").text);
        }
        else {
            if ($("#txtPROFILE_PRODUCT").val().length > 200) {
                $("#lblPROFILE_PRODUCT_ERR").text(GetMessageByID("MSG068").text);
            }
            else {
                $("#lblPROFILE_PRODUCT_ERR").text("");
            }

        }

        if ($("#txtE_MAIL1").val() == "") {
            $("#lblE_MAIL1_ERR").text(GetMessageByID("MSG019").text);
        }
        else {
            $("#lblE_MAIL1_ERR").text("");
            if (!$("#txtE_MAIL1").val().match(/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/)) {
                $("#lblE_MAIL1_ERR").text(GetMessageByID("MSG025").text);

            }
        }
        if ($("#drpVENDOR_KIND").val() == 'NULL') {
            $("#lblVENDOR_KIND_ERR").text(GetMessageByID("MSG056").text);
        }
        else {
            $("#lblVENDOR_KIND_ERR").text("");
        }
        /*if(document.all.drpDELIVERY_TERM.value=='NULL')
		{
			document.all.lblDELIVERY_TERM_ERR.innerText=GetMessageByID("MSG056").text;
		}
		else
		{
			document.all.lblDELIVERY_TERM_ERR.innerText="";
		}*/
        /*if (document.all.txtFAX2.value!="")
		{
			if(isNaN(document.all.txtFAX2.value))
			{
				document.all.lblFAX2_ERR.innerText=GetMessageByID("MSG024").text;
			}
			else
			{
				document.all.lblFAX2_ERR.innerText="";
			}
		}
		
		if (document.all.txtTEL2.value!="")
		{
			if(isNaN(document.all.txtTEL2.value))
			{
				document.all.lblTEL2_ERR.innerText=GetMessageByID("MSG024").text;
			}
			else
			{
				document.all.lblTEL2_ERR.innerText="";
			}
		}*/
        if ($("#txtE_MAIL2").val() != "") {
            if (!$("#txtE_MAIL2").val().match(/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/)) {
                $("#lblE_MAIL2_ERR").text(GetMessageByID("MSG025").text);

            }
            else {
                $("#lblE_MAIL2_ERR").text("");
            }
        }
        else {
            $("#lblE_MAIL2_ERR").text("");
        }

        if ($("#txtE_MAIL3").val() != "") {
            if (!$("#txtE_MAIL3").val().match(/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/)) {
                $("#lblE_MAIL3_ERR").text(GetMessageByID("MSG025").text);

            }
            else {
                $("#lblE_MAIL3_ERR").text("");
            }
        }
        else {
            $("#lblE_MAIL3_ERR").text("");
        }


        if ($("#DIV2") != undefined) {
            //BENEFICIARYS_AC_NO
            if ($("#txtBANK_NAME").val() == "") {
                $("#lblBANK_NAME_ERR").text(GetMessageByID("MSG019").text);
            }
            else {
                $("#lblBANK_NAME_ERR").text("");
            }
            if ($("#txtBANK_ADDRESS").val() == "") {
                $("#lblBANK_ADDRESS_ERR").text(GetMessageByID("MSG019").text);
            }
            else {
                $("#lblBANK_ADDRESS_ERR").text("");
            }

            if ($("#txtAC_NO_1").val() == "") {
                $("#lblAC_NO_ERR").text(GetMessageByID("MSG019").text);
            }
            else {
                $("#lblAC_NO_ERR").text("");
            }

            if ($("#drpCURRENCY_1").val() == "") {
                $("#lblCURRENCY_ERR").text(GetMessageByID("MSG037").text);
            }
            else {
                $("#lblCURRENCY_ERR").text("");
            }

        }
        if ($("#DIV3") != undefined) {
            if ($("#txtABA_NO").val() == "") {
                $("#lblABA_NO_ERR").text(GetMessageByID("MSG019").text);
            }
            else {
                $("#lblABA_NO_ERR").text("");
            }
            if ($("#txtSORT_CODE").val() == "") {
                $("#lblSORT_CODE_ERR").text(GetMessageByID("MSG019").text);
            }
            else {
                $("#lblSORT_CODE_ERR").text("");
            }
            if ($("#txtCHIPS").val() == "") {
                $("#lblCHIPS_ERR").text(GetMessageByID("MSG019").text);
            }
            else {
                $("#lblCHIPS_ERR").text("");
            }
            if ($("#txtLOCAL_CLEARING_BANK_CODE").val() == "") {
                $("#lblLOCAL_CLEARING_BANK_CODE_ERR").text(GetMessageByID("MSG019").text);
            }
            else {
                $("#lblLOCAL_CLEARING_BANK_CODE_ERR").text("");
            }

            if ($("#txtFEDWIRD_NO").val() == "") {
                $("#lblFEDWIRD_NO_ERR").text(GetMessageByID("MSG019").text);
            }
            else {
                $("#lblFEDWIRD_NO_ERR").text("");
            }

            if ($("#txtSWIFT_CODE").val() != undefined) {
                var chk1 = false;
                var chk2 = false;
                if (!isNaN($("#txtSWIFT_CODE").val().substr(0, 2))) {
                    chk1 = true;
                    $("#lblSWIFT_CODE_ERR").text(GetMessageByID("MSG026").text);
                    if (isNaN($("#txtSWIFT_CODE").val().substr(2, 6))) {
                        chk2 = true;
                        //
                    }
                }
                else {
                    if (isNaN($("#txtSWIFT_CODE").val().substr(2, 6))) {
                        //	chk2=true;
                        // 2008/08/26 拿掉 swift code 末六碼一定要數字之限制 By Joe

                        // document.all.lblSWIFT_CODE_ERR.innerText=GetMessageByID("MSG027").text;
                    }
                    else {
                        $("#lblSWIFT_CODE_ERR").text("");
                    }
                }


                if (chk1 && chk2) {
                    $("#lblSWIFT_CODE_ERR").text(GetMessageByID("MSG026").text + GetMessageByID("MSG025").text);
                }
            }
            else {

                $("#lblSWIFT_CODE_ERR").text("");
            }

            if ($("#drpCURRENCY_TYPE").val() == "USD") {
                $("#lblACH").css("color", "red");
                if ($("#txtACH").val() == "") {
                    $("#lblACH_ERR").text(GetMessageByID("MSG019").text);
                }
                else {
                    $("#lblACH_ERR").text("");
                }
                //
                if ($("#lblVENDOR_NO_ERR").text() == "" && $("#lblVND_PASSWORD_ERR").text() == "" && $("#lblVENDOR_CHINESENAME_ERR").text() == "" && $("#lblVENDOR_ENGLISHNAME_ERR").text() == "" && $("#lblTEL1_ERR").text() == "" && $("#lblFAX1_ERR").text() == "" && $("#lblTEL2_ERR").text() == "" && $("#lblFAX2_ERR").text() == "" && $("#lblE_MAIL1_ERR").text() == "" && $("#lblE_MAIL2_ERR").text() == "" && $("#lblBANK_NAME_ERR").text() == "" && $("#lblBANK_ADDRESS_ERR").text() == "" && $("#lblABA_NO_ERR").text() == "" && $("#lblSORT_CODE_ERR").text() == "" && $("#lblCHIPS_ERR").text() == "" && $("#lblLOCAL_CLEARING_BANK_CODE_ERR").text() == "" /*&& $("#lblOTHERS_ERR").text()=="" */ && $("#lblFEDWIRD_NO_ERR").text() == "" && $("#lblACH_ERR").text() == "" && $("#lblSWIFT_CODE_ERR").text() == "" && $("#lblAC_NO_ERR").text() == "" && $("#lblCURRENCY_ERR").text() == "" /*&& document.all.lblDELIVERY_TERM_ERR.innerText=="" && document.all.lblDELIVERY_TERM_ERR.innerText==""*/ && $("#lblPROFILE_PRODUCT_ERR").text() == "") {
                    return true;
                }
                else {
                    alert(GetMessageByID("MSG020").text);
                    return false;
                }
            }
            else {

                if ($("#drpCURRENCY_TYPE").val() == "EUR") {
                    $("#lblIACH").css("color", "red");
                    if ($("#txtIACH").val() == "") {
                        $("#lblIACH_ERR").text(GetMessageByID("MSG019").text);
                    }
                    else {
                        $("#lblIACH_ERR").text("");
                    }
                    //
                    if ($("#lblVENDOR_NO_ERR").text() == "" && $("#lblVND_PASSWORD_ERR").text() == "" && $("#lblVENDOR_CHINESENAME_ERR").text() == "" && $("#lblVENDOR_ENGLISHNAME_ERR").text() == "" && $("#lblTEL1_ERR").text() == "" && $("#lblFAX1_ERR").text() == "" && $("#lblTEL2_ERR").text() == "" && $("#lblFAX2_ERR").text() == "" && $("#lblE_MAIL1_ERR").text() == "" && $("#lblE_MAIL2_ERR").text() == "" && $("#lblBANK_NAME_ERR").text() == "" && $("#lblBANK_ADDRESS_ERR").text() == "" && $("#lblABA_NO_ERR").text() == "" && $("#lblSORT_CODE_ERR").text() == "" && $("#lblCHIPS_ERR").text() == "" && $("#lblLOCAL_CLEARING_BANK_CODE_ERR").text() == "" /*&& document.all.lblOTHERS_ERR.text()=="" */ && $("#lblFEDWIRD_NO_ERR").text() == "" && $("#lblIACH_ERR").text() == "" && $("#lblSWIFT_CODE_ERR").text() == "" && $("#lblAC_NO_ERR").text() == "" && $("#lblCURRENCY_ERR").text() == "" /*&& document.all.lblDELIVERY_TERM_ERR.text()=="" && document.all.lblDELIVERY_TERM_ERR.text()==""*/ && $("#lblPROFILE_PRODUCT_ERR").text() == "") {
                        return true;
                    }
                    else {
                        alert(GetMessageByID("MSG020").text);
                        return false;
                    }
                }
                else {

                    //
                    if ($("#lblVENDOR_NO_ERR").text() == "" && $("#lblVND_PASSWORD_ERR").text() == "" && $("#lblVENDOR_CHINESENAME_ERR").text() == "" && $("#lblVENDOR_ENGLISHNAME_ERR").text() == "" && $("#lblTEL1_ERR").text() == "" && $("#lblFAX1_ERR").text() == "" && $("#lblTEL2_ERR").text() == "" && $("#lblFAX2_ERR").text() == "" && $("#lblE_MAIL1_ERR").text() == "" && $("#lblE_MAIL2_ERR").text() == "" && $("#lblBANK_NAME_ERR").text() == "" && $("#lblBANK_ADDRESS_ERR").text() == "" && $("#lblABA_NO_ERR").text() == "" && $("#lblSORT_CODE_ERR").text() == "" && $("#lblCHIPS_ERR").text() == "" && $("#lblLOCAL_CLEARING_BANK_CODE_ERR").text() == ""/* && document.all.lblOTHERS_ERR.text()==""*/ && $("#lblFEDWIRD_NO_ERR").text() == "" && $("#lblSWIFT_CODE_ERR").text() == "" && $("#lblAC_NO_ERR").text() == "" && $("#lblCURRENCY_ERR").text() == "" /*&& document.all.lblDELIVERY_TERM_ERR.text()=="" && document.all.lblDELIVERY_TERM_ERR.text()==""*/ && $("#lblPROFILE_PRODUCT_ERR").text() == "") {
                        return true;
                    }
                    else {
                        alert(GetMessageByID("MSG020").text);
                        return false;
                    }

                }
            }
        }
        else {   //
            if ($("#DIV3") != undefined) {
                if ($("#lblVENDOR_NO_ERR").text() == "" && $("#lblVND_PASSWORD_ERR").text() == "" && $("#lblVENDOR_CHINESENAME_ERR").text() == "" && $("#lblVENDOR_ENGLISHNAME_ERR").text() == "" && $("#lblTEL1_ERR").text() == "" && $("#lblFAX1_ERR").text() == "" && $("#lblTEL2_ERR").text() == "" && $("#lblFAX2_ERR").text() == "" && $("#lblE_MAIL1_ERR").text() == "" && $("#lblE_MAIL2_ERR").text() == "" && $("#lblBANK_NAME_ERR").text() == "" && $("#lblBANK_ADDRESS_ERR").text() == "" && $("#lblABA_NO_ERR").text() == "" && $("#lblSORT_CODE_ERR").text() == "" && $("#lblCHIPS_ERR").text() == "" && $("#lblLOCAL_CLEARING_BANK_CODE_ERR").text() == "" && $("#lblFEDWIRD_NO_ERR").text() == "" && $("#lblSWIFT_CODE_ERR").text() == "" && $("#lblAC_NO_ERR").text() == "" && $("#lblCURRENCY_ERR").text() == "" /* && document.all.lblDELIVERY_TERM_ERR.text()=="" && document.all.lblDELIVERY_TERM_ERR.text()==""*/ && $("#lblPROFILE_PRODUCT_ERR").text() == "") {
                    return true;
                }
                else {
                    alert(GetMessageByID("MSG020").text);
                    return false;
                }
            }
            else {
                if ($("#DIV2") != undefined) {
                    if ($("#lblVENDOR_NO_ERR").text() == "" && $("#lblVND_PASSWORD_ERR").text() == "" && $("#lblVENDOR_CHINESENAME_ERR").text() == "" && $("#lblVENDOR_ENGLISHNAME_ERR").text() == "" && $("#lblTEL1_ERR").text() == "" && $("#lblFAX1_ERR").text() == "" && $("#lblTEL2_ERR").text() == "" && $("#lblFAX2_ERR").text() == "" && $("#lblE_MAIL1_ERR").text() == "" && $("#lblE_MAIL2_ERR").text() == "" && $("#lblBANK_NAME_ERR").text() == "" && $("#lblBANK_ADDRESS_ERR").text() == "" && $("#lblAC_NO_ERR").text() == "" && $("#lblCURRENCY_ERR").text() == "" /*&& $("#lblDELIVERY_TERM_ERR").text()==""  && document.all.lblDELIVERY_TERM_ERR.text()==""*/ && $("#lblPROFILE_PRODUCT_ERR").text() == "") {
                        return true;

                    }
                    else {
                        alert(GetMessageByID("MSG020").text);
                        return false;

                    }
                }
                else {
                    if ($("#lblVENDOR_NO_ERR").text() == "" && $("#lblVND_PASSWORD_ERR").text() == "" && $("#lblVENDOR_CHINESENAME_ERR").text() == "" && $("#lblVENDOR_ENGLISHNAME_ERR").text() == "" && $("#lblTEL1_ERR").text() == "" && $("#lblFAX1_ERR").text() == "" && $("#lblTEL2_ERR").text() == "" && $("#lblFAX2_ERR").text() == "" && $("#lblE_MAIL1_ERR").text() == "" && $("#lblE_MAIL2_ERR").text() == "" /* && document.all.lblDELIVERY_TERM_ERR.text()=="" && document.all.lblDELIVERY_TERM_ERR.text()==""*/ && $("#lblPROFILE_PRODUCT_ERR").text() == "") {
                        return true;

                    }
                    else {
                        alert(GetMessageByID("MSG020").text);
                        return false;

                    }
                }
            }

        }

    }
    catch (e) {
        alert(e.Message);
        return false;
    }
    finally {

    }
}

function chk_CURRENCY_TYPE() {
    if ($("#DIV3") != undefined) {
        if ($("#drpCURRENCY_TYPE").val() == "USD") {
            $("#lblACH").css("color", "red");
            $("#txtACH").attr("disabled", false);

        }
        else {
            $("#lblACH").css("color", "black");

            $("#txtACH").attr("disabled", true);
            $("#txtACH").val("");

        }
        if ($("#drpCURRENCY_TYPE").val() == "EUR") {
            $("#lblIACH").css("color", "red");
            $("#txtIACH").attr("disabled", false);

        }
        else {
            $("#lblIACH").css("color", "black");
            $("#txtIACH").attr("disabled", true);
            $("#txtIACH").val("");

        }
    }

}


function chk_VENDOR_TYPE() {
    if ($("#rdoVENDOR_TYPE_0").prop("checked")) {
        $("#txtVENDOR_NO").val("");
        $("#txtVENDOR_NO").attr("disabled", false);
        $("#lblVENDOR_ENGLISHNAME").css("color", "black");
        $("#lblVENDOR_ENGLISHNAME_ERR").text("");
        $("#lblVENDOR_CHINESENAME").css("color", "red");
        $("#lblVENDOR_NO_ERR").text("");
        $("#drpCOUNTRY").val('Taiwan');
        $("#drpINVOICE_COUNTRY").val('Taiwan');

    }
    else {
        $("#txtVENDOR_NO").val("VRXXXXXXXX");
        $("#txtVENDOR_NO").className = "text_EnableView";

        $("#txtVENDOR_NO").attr("disabled", true);
        $("#lblVENDOR_ENGLISHNAME").css("color", "red");
        $("#lblVENDOR_CHINESENAME").css("color", "black");
        $("#lblVENDOR_CHINESENAME_ERR").text("");
        $("#lblVENDOR_NO_ERR").text("");
        //$("#txtVENDOR_NO").class="text_EnableView";
    }

}

function chkMAIL(o, o1) {

    var chk = true;

    if ($(o).val != "") {
        if (!$(o).val().match(/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/)) {
            $(o1).text(GetMessageByID("MSG025").text);
            //GetMessageByIDAjax("MSG025", o1);				
            chk = false;
        }
        else {
            $(o1).text("");
            chk = true;
        }
    }
    return chk;
}

function Vendor_Id_Check(obj) {
    obj = $(obj);
    var Chk_Number = "12121241";
    var Result_A = 0;
    var Result_B = 0;
    var Result_C = 0;
    var Result_D = "";
    var Result_E = 0;
    var num = 0;

    try {
        if ($("#drpVENDOR_KIND").val() == "CTM" || $("#drpVENDOR_KIND").val() == "ESC") {
        }
        else {
            if ($(obj).val() != "") {
                if ($(obj).val().length == 8) {
                    for (var i = 0; i < 8; i++) {
                        Result_A = Number(Chk_Number.substr(i, 1)) * Number($(obj).val().substr(i, 1));
                        if (String(Result_A).length >= 2) {
                            if (Result_A == 28) //			
                            {
                                Result_B = 0;
                                num = num + 1;
                            }
                            else {
                                Result_B = parseInt(Result_A / 10) + Result_A % 10;
                            }
                        }
                        else {
                            Result_B = Result_A;
                        }

                        Result_C = Result_C + Result_B;
                        Result_D = Result_D + String(Result_B);	//		
                    }

                    if (Result_C % 10 == 0) {
                        $("#lblVENDOR_NO_ERR").text("");

                        var msg = document.createElement("TITLE");
                        try {
                            $.ajax({
                                type: "POST",
                                async: false,
                                url: GetLocalPath() + "/VND/VNDW0010.asmx/Query_VENDOR_NO",
                                dataType: 'json',
                                contentType: "application/json;charset=utf-8",
                                data: "{ 'VENDOR_NO': '" + $(obj).val().toUpperCase() + "' }",
                                success: function (data) {
                                    msg.text = data.d
                                },
                                error: function (xhr, ajaxOptions, thrownError) {
                                    alert(xhr.status);
                                    alert(thrownError);
                                }
                            });
                        }
                        catch (e) {
                            return e;
                        }

                        if (msg.text == "true") {
                            $("#lblVENDOR_NO_ERR").text(GetMessageByID("MSG028").text);
                            return false;
                        }
                        else {
                            return true;
                        }

                        //var XmlDocu = null;
                        //	addFormNode("VNDW0010","Query_VENDOR_NO");
                        //	addCommandNode("B2B_VENDOR","sel");
                        //	addParameterNode("VENDOR_NO","string",$(obj).val().toUpperCase());
                        //	xmlstr = getXML();
                        //	XmlDocu = ExecuteQuery(xmlstr);
                        //	var htmlDataSet = new dataSetObject();
                        //	htmlDataSet.load(XmlDocu);
                        //	if(htmlDataSet != undefined)
                        //	{
                        //		var Result = htmlDataSet.getTable("info").rows[0].getAttribute("ReturnCode");
                        //		if (Result == "000")
                        //		{
                        //			$("#lblVENDOR_NO_ERR").text(GetMessageByID("MSG028").text);
                        //			return false;
                        //		}
                        //		else
                        //		{
                        //			return true;
                        //		}
                        //	}


                    }
                    else {
                        if (num == 1) {
                            if ((Result_C + 1) % 10 == 0) {
                                $("#lblVENDOR_NO_ERR").text("");

                                var msg = document.createElement("TITLE");
                                try {
                                    $.ajax({
                                        type: "POST",
                                        async: false,
                                        url: GetLocalPath() + "/VND/VNDW0010.asmx/Query_VENDOR_NO",
                                        dataType: 'json',
                                        contentType: "application/json;charset=utf-8",
                                        data: "{ 'VENDOR_NO': '" + $(obj).val().toUpperCase() + "' }",
                                        success: function (data) {
                                            msg.text = data.d
                                        },
                                        error: function (xhr, ajaxOptions, thrownError) {
                                            alert(xhr.status);
                                            alert(thrownError);
                                        }
                                    });
                                }
                                catch (e) {
                                    return e;
                                }

                                if (msg.text == "true") {
                                    $("#lblVENDOR_NO_ERR").text(GetMessageByID("MSG028").text);
                                    return false;
                                }
                                else {
                                    return true;
                                }

                                //var XmlDocu = null;
                                //addFormNode("VNDW0010", "Query_VENDOR_NO");
                                //addCommandNode("B2B_VENDOR", "sel");
                                //addParameterNode("VENDOR_NO", "string", obj.val().toUpperCase());
                                //xmlstr = getXML();
                                //XmlDocu = ExecuteQuery(xmlstr);
                                //var htmlDataSet = new dataSetObject();
                                //htmlDataSet.load(XmlDocu);
                                //if (htmlDataSet != undefined) {
                                //    var Result = htmlDataSet.getTable("info").rows[0].getAttribute("ReturnCode");
                                //    if (Result == "000") {
                                //        $("#lblVENDOR_NO_ERR").text(GetMessageByID("MSG028").text);
                                //        return false;
                                //    }
                                //    else {
                                //        return true;
                                //    }
                                //}

                            }
                            else {
                                $("#lblVENDOR_NO_ERR").text(GetMessageByID("MSG029").text);
                                return false;
                            }
                        }
                        else {
                            $("#lblVENDOR_NO_ERR").text(GetMessageByID("MSG029").text);
                            return false;
                        }

                    }
                }
                else {
                    $("#lblVENDOR_NO_ERR").text(GetMessageByID("MSG029").text);
                    return false;
                }
            }
            else {
                $("#lblVENDOR_NO_ERR").text(GetMessageByID("MSG019").text);
            }
        }
    }
    catch (e) {
        alert(e.Message);
    }

}

function UPDATE_PASSWORD() {
    //var ReturnValue =window.open("/smasb2b/VND/VNDW0011.aspx");
    var ReturnValue = window.showModalDialog('/smasb2b/VND/VNDW0011.aspx', null, 'dialogWidth=420px;dialogHeight=250px;center=yes;border=thin;help=no;status=no;resizable=no;', false);


    if (ReturnValue != undefined) {
        /* Mark By Ben P3512S0159-針對B2B網站SCA弱點掃描修正程式
		document.all.txtVND_PASSWORD.style.display="";
		document.all.txtVND_PASSWORD.value=ReturnValue;
		*/
        /* add By Ben P3512S0159-針對B2B網站SCA弱點掃描修正程式*/
        $("#txtVND_PASSWORD").css("display", "block");
        $("#txtVND_PASSWORD").val(ReturnValue);
    }
    return false;
}
/*function DELIVERY_TERM()
{
	if (document.all.drpDELIVERY_TERM.value=="FOB_Seaport")
	{
		document.all.lblSEAPORT.style.display=""; 
		document.all.txtSEAPORT.style.display=""; 
	}
	else
	{	
		document.all.lblSEAPORT.style.display="none"; 
		document.all.txtSEAPORT.style.display="none"; 
	}
}*/

function VENDOR_ENGLISHNAME() {
    if ($("#txtBENEFICIARY_NAME") != undefined) {
        if ($("#rdoVENDOR_TYPE_1").prop("checked")) {
            $("#txtBENEFICIARY_NAME").val($("#txtVENDOR_ENGLISHNAME").val());
        }
    }
}

function VENDOR_CHINESENAME() {
    if ($("#txtBENEFICIARY_NAME") != undefined) {
        if ($("#rdoVENDOR_TYPE_0").prop("checked")) {
            $("#txtBENEFICIARY_NAME").val($("#txtVENDOR_CHINESENAME").val());
        }
    }

}

function CLASS_DESC() {
    var result = window.showModalDialog(program_id, '', dialogStr, true);

}

